User Guide > Getting Started > Tutorial: Create Your First Project |
This step-by-step tutorial will guide you to build a complete C# application that analyzes 1D barcodes from an example image and outputs the value and type to a message box. This tutorial uses ImagXpress to handle any preprocessing before passing the image to the BarcodeXpress engine to be analyzed.
For this tutorial, we would recommend using Visual Studios 12 or higher.
Copy Code | |
---|---|
private Accusoft.ImagXpressSdk.ImageXView imageXView1; private Accusoft.ImagXpressSdk.ImagXpress imagXpress1; private System.Windows.Forms.Button button1; private System.Windows.Forms.Button button2; |
Copy Code | |
---|---|
private Accusoft.BarcodeXpressSdk.BarcodeXpress bx; |
Copy Code | |
---|---|
using Accusoft.BarcodeXpressSdk; |
Copy Code | |
---|---|
bx = new BarcodeXpress(); //bx.Licensing.SetSolutionName("SolutionNameGoesHere"); //bx.Licensing.SetSolutionKey(keynumber, keynumber, keynumber, keynumber); |
Copy Code | |
---|---|
try { if (imageXView1.Image != null) imageXView1.Image.Dispose(); imageXView1.Image = Accusoft.ImagXpressSdk.ImageX.FromFile(imagXpress1, @"YourPathToYourBarcodeImage\BarcodeImage.bmp"); } catch (Accusoft.ImagXpressSdk.ImagXpressException ex) { MessageBox.Show("Error Opening File. ImagXpress Error: " + ex.Message); } |
Copy Code | |
---|---|
try { Accusoft.BarcodeXpressSdk.Result[] results = bx.reader.Analyze(imageXView1.Image); for (int i = 0; i < results.Length; i++) { string strResult = ""; Accusoft.BarcodeXpressSdk.Result curResult = (Accusoft.BarcodeXpressSdk.Result)results.GetValue(i); strResult += "Symbol #" + i + "\r" + "Type = " + curResult.BarcodeName + "\r"; strResult += "Value: = " + i + curResult.BarcodeValue + "\r"; strResult += "\n"; MessageBox.Show(strResult, "Barcode Result", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Accusoft.ImagXpressSdk.ImagXpressException ex) { MessageBox.Show("Error Opening File. ImagXpress Error: " + ex.Message); } |
Copy Code | |
---|---|
bx.Dispose(); |